package com.zc.controller.wj;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class WjController {

    @Autowired
    WjService wjService;

        @RequestMapping("queryall")
        @ResponseBody
        public List<Map> queryall(@RequestParam(value = "username",required = false)String username, @RequestParam(value = "pass",required = false) String pass){
            List<Map> list =wjService.query();
            return list;
        }

        @RequestMapping("add")
        @ResponseBody
        public String add(Wjpojo wjpojo){
            wjpojo.setName("wj");
            wjpojo.setAge(22);
            wjpojo.setSex("男");
            wjService.add(wjpojo);
            return "1";
        }

    @RequestMapping("del")
    @ResponseBody
    public String del(@RequestParam(value = "id",required = false)Integer id){
        id=23;
        wjService.delete(id);
        return "1";
    }

    @RequestMapping("update")
    @ResponseBody
    public String update(Wjpojo wjpojo){
        wjpojo.setId(20);
        wjpojo.setName("wj");
        wjpojo.setAge(22);
        wjpojo.setSex("男");
        wjService.update(wjpojo);
        return "1";
    }
}
